package game.module.battleReport.dao;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.module.battleReport.bean.PlayerReport;
import game.module.turntables.dao.TurntableCache;


public class PlayerReportCache {
	
    private static Logger logger = LoggerFactory.getLogger(PlayerReportCache.class);
	
	static class SingletonHolder {
		static PlayerReportCache instance = new PlayerReportCache();
	}

	public static PlayerReportCache getInstance() {
		return SingletonHolder.instance;
	}
	
	public Map<Integer,List<PlayerReport>> playerReportCache = new ConcurrentHashMap<Integer,List<PlayerReport>>();
	
	public void loadFromDb(int PlayerId) {
		if(playerReportCache.containsKey(PlayerId)) {
			return;
		}
		List<PlayerReport> playerreport = PlayReportDBDao.getInstance().getPlayerReports(PlayerId);
		if(playerreport!=null) {
			playerReportCache.put(PlayerId, playerreport);
		}
		logger.info("playerId={} load battlereport",PlayerId);
	}
	
	/**
	 * 删除
	 * */
	public void remove(int playerId) {
		playerReportCache.remove(playerId);
	}
	/**
	 * 获得设置
	 * */
	public List<PlayerReport> getBattleReport(int playerId){
		return playerReportCache.get(playerId);
	}
}
